import { getPushList } from '../../../../services/push_service';

export default {
  namespace: 'pushRule',
  state: {
    pushListData: {
      code: '',
      message: '',
      data: [],
    },
  },

  effects: {
    *GetPushList({ payload, callback }, { call, put }) {
      const response = yield call(getPushList, payload);
      if (typeof response === 'undefined') {
        return;
      }
      yield put({
        type: 'savePushListData',
        payload: response,
      });
      if (callback) callback(response);
    },
  },

  reducers: {
    savePushListData(state, action) {
      return {
        ...state,
        pushListData: action.payload,
      };
    },
  },
};
